define(['handlebars','js/graph/graphView','text!js/patient/dept-list-item.hbs','text!js/patient/patient-list-item.hbs'],
	function(Handlebars,graph,deptSource,patientSource) {
	var $$ = Dom7;
	
	
	function renderDept(params) {
		
		var template = Handlebars.compile(deptSource);
		var _content = template(params.model);
		
		var _el = $('#patient-list-page .content')
		_el.html(_content);

		bindEvents(params.bindings);
		
	}
	
	
	/**
	 * 生成饼图
	 * @param params.title	
	 * @param params.container
	 * @param params.onClick
	 * @param params.data
	 * @param params.imgSrc
	 */
	function renderPie(params){		
		
		var model = params.model
		
		$('#patient-list-page .biz-media').attr('src',model.imgSrc);
		$('#patient-list-page .biz-title').html(model.title);
		$('#patient-list-page .biz-subtitle').html(model.subtitle);
		var _el = $('#patient-list-page .content')
		_el.html('<div id="pie-content"></div>')
		
		graph.renderPie(model);
		
	}	
	
	
	
	/**
	 * 显示患者清单
	 */
	function renderPatient(params) {
		
		var template = Handlebars.compile(patientSource);
		var _content = template(params.model);
		
		var _el = $('#patient-list-page ul')
		_el.html(_content);

		bindEvents(params.bindings);
		
	}

	function bindEvents(bindings) {
		for (var i in bindings) {
			$$(bindings[i].element).on(bindings[i].event, bindings[i].handler);
		}
	}

	return {
		renderDept	: renderDept,
		renderPie	: renderPie
	}
});